package com.ruoyi.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manage.domain.SurgeryDeviceDetail;
import com.ruoyi.manage.service.ISurgeryDeviceDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 术中清点记录Controller
 * 
 * @author zww
 * @date 2025-07-08
 */
@Api
@RestController
@RequestMapping("/manage/devicedetail")
public class SurgeryDeviceDetailController extends BaseController
{
    @Autowired
    private ISurgeryDeviceDetailService surgeryDeviceDetailService;

    /**
     * 查询术中清点记录列表
     */
    @ApiOperation("list")
    @PreAuthorize("@ss.hasPermi('manage:devicedetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(SurgeryDeviceDetail surgeryDeviceDetail)
    {
        startPage();
        List<SurgeryDeviceDetail> list = surgeryDeviceDetailService.selectSurgeryDeviceDetailList(surgeryDeviceDetail);
        return getDataTable(list);
    }

    /**
     * 导出术中清点记录列表
     */
    @PreAuthorize("@ss.hasPermi('manage:devicedetail:export')")
    @Log(title = "术中清点记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SurgeryDeviceDetail surgeryDeviceDetail)
    {
        List<SurgeryDeviceDetail> list = surgeryDeviceDetailService.selectSurgeryDeviceDetailList(surgeryDeviceDetail);
        ExcelUtil<SurgeryDeviceDetail> util = new ExcelUtil<SurgeryDeviceDetail>(SurgeryDeviceDetail.class);
        util.exportExcel(response, list, "术中清点记录数据");
    }

    /**
     * 获取术中清点记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:devicedetail:query')")
    @GetMapping(value = "/{surgeryDeviceDetailId}")
    public AjaxResult getInfo(@PathVariable("surgeryDeviceDetailId") Long surgeryDeviceDetailId)
    {
        return success(surgeryDeviceDetailService.selectSurgeryDeviceDetailBySurgeryDeviceDetailId(surgeryDeviceDetailId));
    }


    @PostMapping
    public AjaxResult add(@RequestBody List<SurgeryDeviceDetail> surgeryDeviceDetailList)
    {
        return toAjax(surgeryDeviceDetailService.insertSurgeryDeviceDetail(surgeryDeviceDetailList));
    }

    /**
     * 修改术中清点记录
     */
    @PreAuthorize("@ss.hasPermi('manage:devicedetail:edit')")
    @Log(title = "术中清点记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SurgeryDeviceDetail surgeryDeviceDetail)
    {
        return toAjax(surgeryDeviceDetailService.updateSurgeryDeviceDetail(surgeryDeviceDetail));
    }

    /**
     * 删除术中清点记录
     */
    @ApiOperation("通过id删除")
    @PreAuthorize("@ss.hasPermi('manage:devicedetail:remove')")
    @Log(title = "术中清点记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{surgeryDeviceDetailIds}")
    public AjaxResult remove(@PathVariable Long[] surgeryDeviceDetailIds)
    {
        return toAjax(surgeryDeviceDetailService.deleteSurgeryDeviceDetailBySurgeryDeviceDetailIds(surgeryDeviceDetailIds));
    }
}
